﻿using System.IO;
using System.Security.Cryptography;
using System.Text;

namespace DuplicateFileFinder.Business
{
    public class FileHasher
    {
        public string ComputeHash(string filePath)
        {
            var md5 = new MD5CryptoServiceProvider();
            try
            {
                var fsin = new FileStream(filePath, FileMode.Open);
                md5.ComputeHash(fsin);
            }
            catch (IOException)
            {
                return null;
            }
            return UTF8Encoding.UTF8.GetString(md5.Hash);
        }
    }
}
